﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Citrix.XenApp.Commands;

namespace Citrix.XaAdminMobile.Model
{
    /// <summary>
    /// The model interface for a XenApp session. If session sharing is being used and multiple
    /// apps get launched in the same session, then we actually get multiple instances of
    /// ISessionModel.
    /// </summary>
    internal interface ISessionModel : INotifyPropertyChanged
    {
        #region Summary properties

        /// <summary>
        /// The user account display name
        /// </summary>
        string AccountName { get; }

        /// <summary>
        /// The name of the published application associated with this session
        /// </summary>
        string BrowserName { get; }

        /// <summary>
        /// The name of the client device. For windows clients this is generally the Netbios
        /// name of the computer.
        /// </summary>
        string ClientName { get; }

        /// <summary>
        /// The color depth of the client, or ColorDepth.Unknown if not applicable.
        /// </summary>
        ColorDepth ColorDepth { get; }

        /// <summary>
        /// The last connection time of the session.
        /// </summary>
        DateTime? ConnectTime { get; }

        /// <summary>
        /// The last disconnect time of this session, in UTC. Null if not applicable.
        /// </summary>
        DateTime? DisconnectTime { get; }

        /// <summary>
        /// The time that this session logged on, in UTC. Null if not applicable.
        /// </summary>
        DateTime? LogOnTime { get; }

        /// <summary>
        /// The name of the XenApp server the session is running on.
        /// </summary>
        string ServerName { get; }

        /// <summary>
        /// The session ID.
        /// </summary>
        Int32? SessionId { get; }

        /// <summary>
        /// The session state.
        /// </summary>
        SessionConnectionState State { get; }

        #endregion

        #region Detailed properties

        /// <summary>
        /// Access session GUID
        /// </summary>
        string AccessSessionGuid { get; }

        /// <summary>
        /// The state of the app launched in the session.
        /// </summary>
        SessionApplicationState? ApplicationState { get; }

        /// <summary>
        /// The client address.
        /// </summary>
        string ClientAddress { get; }

        /// <summary>
        /// Client buffer size for HDX video.
        /// </summary>
        string ClientBuffers { get; }

        /// <summary>
        /// The build number of the client.
        /// </summary>
        Int32? ClientBuildNumber { get; }

        /// <summary>
        /// ClientCacheDisk
        /// </summary>
        uint? ClientCacheDisk { get; }

        /// <summary>
        /// ClientCacheLow
        /// </summary>
        uint? ClientCacheLow { get; }

        /// <summary>
        /// ClientCacheMinBitmapSize
        /// </summary>
        uint? ClientCacheMinBitmapSize { get; }

        /// <summary>
        /// ClientCacheSize
        /// </summary>
        uint? ClientCacheSize { get; }

        /// <summary>
        /// ClientCacheTiny
        /// </summary>
        uint? ClientCacheTiny { get; }

        /// <summary>
        /// ClientCacheXms
        /// </summary>
        uint? ClientCacheXms { get; }

        /// <summary>
        /// The client installation director.
        /// </summary>
        string ClientDirectory { get; }

        /// <summary>
        /// The client ID.
        /// </summary>
        UInt32? ClientId { get; }

        /// <summary>
        /// The V4 IP address of the client.
        /// </summary>
        string ClientIPV4 { get; }

        /// <summary>
        /// An identifier based on client state like IP address, name, etc. This ID is unique
        /// most of the time.
        /// </summary>
        Int32? ClientProductId { get; }

        /// <summary>
        /// The type of client running this session.
        /// </summary>
        string ClientType { get; }

        /// <summary>
        /// The time of day that information about this session was retreived, in UTC. Null if
        /// not applicable.
        /// </summary>
        DateTime? CurrentTime { get; }

        /// <summary>
        /// Whether direct X is enabled on the client.
        /// </summary>
        bool? DirectXEnabled { get; }

        /// <summary>
        /// Encryption level of the session.
        /// </summary>
        EncryptionLevel EncryptionLevel { get; }

        /// <summary>
        /// Whether flash is enabled on the client.
        /// </summary>
        bool? FlashEnabled { get; }

        /// <summary>
        /// The horizontal resolution of the session in pixels, or zero if not applicable.
        /// </summary>
        int? HorizontalResolution { get; }

        /// <summary>
        /// The last input time of this session, in UTC. Null if not applicable.
        /// </summary>
        DateTime? LastInputTime { get; }

        /// <summary>
        /// The protocol of this session.
        /// </summary>
        SessionProtocolType? Protocol { get; }

        /// <summary>
        /// The server side buffer size for HDX video.
        /// </summary>
        string ServerBuffers { get; }

        /// <summary>
        /// The session name.
        /// </summary>
        string SessionName { get; }

        /// <summary>
        /// Whether or not USB is enabled on the client.
        /// </summary>
        bool? UsbEnabled { get; }

        /// <summary>
        /// The vertical resolution of the session in pixels, or zero if not applicable.
        /// </summary>
        int? VerticalResolution { get; }

        /// <summary>
        /// The Virtual IP address of the session, or empty if Virtual IP is not in use.
        /// </summary>
        string VirtualIP { get; }

        /// <summary>
        /// Whether Windows Media Player is enabled on the client.
        /// </summary>
        bool? WmpEnabled { get; }

        #endregion

        #region Support properties and methods

        /// <summary>
        /// True if the full state has ever been loaded for this session, false if only the
        /// summary state has been loaded. Once the full state has been loaded for a session
        /// this property will always return true, even if you do a refresh of just the summary
        /// state.
        /// </summary>
        bool IsFullStateLoaded { get; }

        /// <summary>
        /// Set to true when this model object is loading or reloading it's state from the server.
        /// </summary>
        bool IsLoading { get; }

        /// <summary>
        /// Returns the sessions container object this session belongs to.
        /// </summary>
        ISessionsModel Parent { get; }

        /// <summary>
        /// Refreshes the state of this session from the XenApp farm.
        /// </summary>
        /// <param name="loadFullState">True to load the full state of the session, false just
        /// to load the summary state.</param>
        /// <remarks>
        /// This call is non-blocking, the refresh will occur in a background thread.
        /// </remarks>
        void Refresh(bool loadFullState);

        /// <summary>
        /// Used to track when an action is being executed on a session, and the type of the
        /// action being executed. This is used to present UI feedback for a session.
        /// </summary>
        SessionActionStatus SessionActionStatus { get; set; }

        #endregion
    }
}
